<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="../templates/ui.xhtml">

	<ui:define name="content">

		<h1 class="title ui-widget-header ui-corner-all">ContextMenu</h1>
			<div class="entry">
			<p>ContextMenu can have nested submenus and menuitems.</p>
			
			<h:form id="form">
				
				<p:growl id="messages"/>

                <p:contextMenu style="width:180px">
					<p:submenu label="Ajax Menuitems" icon="ui-icon-refresh">
						<p:menuitem value="Save" actionListener="#{buttonBean.save}" update="messages" icon="ui-icon-disk" />
						<p:menuitem value="Update" actionListener="#{buttonBean.update}" update="messages" icon="ui-icon-arrowrefresh-1-w" />
					</p:submenu>
					<p:submenu label="Non-Ajax Menuitem" icon="ui-icon-newwin">
						<p:menuitem value="Delete" actionListener="#{buttonBean.delete}" update="messages" ajax="false" icon="ui-icon-close"/>
					</p:submenu>
                    <p:separator />
					<p:submenu label="Navigations" icon="ui-icon-extlink">
						<p:submenu label="Prime Links">
							<p:menuitem value="Prime" url="http://www.prime.com.tr" />
							<p:menuitem value="PrimeFaces" url="http://www.primefaces.org" />
						</p:submenu>
                        <p:menuitem value="Mobile" outcome="/mobile/index" icon="ui-icon-signal" />
					</p:submenu>
				</p:contextMenu>
                
			</h:form>
						
			<h3>Source</h3>
			<p:tabView>
				<p:tab title="contextMenuTiered.xhtml">
				<pre name="code" class="xml">
&lt;h:form id="form"&gt;
				
    &lt;p:growl id="messages"/&gt;

    &lt;p:contextMenu style="width:180px"&gt;
        &lt;p:submenu label="Ajax Menuitems" icon="ui-icon-refresh"&gt;
            &lt;p:menuitem value="Save" actionListener="\#{buttonBean.save}" update="messages" icon="ui-icon-disk" /&gt;
            &lt;p:menuitem value="Update" actionListener="\#{buttonBean.update}" update="messages" icon="ui-icon-arrowrefresh-1-w" /&gt;
        &lt;/p:submenu&gt;
        &lt;p:submenu label="Non-Ajax Menuitem" icon="ui-icon-newwin"&gt;
            &lt;p:menuitem value="Delete" actionListener="\#{buttonBean.delete}" update="messages" ajax="false" icon="ui-icon-close"/&gt;
        &lt;/p:submenu&gt;
        &lt;p:separator /&gt;
        &lt;p:submenu label="Navigations" icon="ui-icon-extlink"&gt;
            &lt;p:submenu label="Prime Links"&gt;
                &lt;p:menuitem value="Prime" url="http://www.prime.com.tr" /&gt;
                &lt;p:menuitem value="PrimeFaces" url="http://www.primefaces.org" /&gt;
            &lt;/p:submenu&gt;
            &lt;p:menuitem value="Mobile" outcome="/mobile/index" icon="ui-icon-signal" /&gt;
        &lt;/p:submenu&gt;
    &lt;/p:contextMenu&gt;

&lt;/h:form&gt;
</pre>
				</p:tab>
				<p:tab title="ButtonBean.java">
			<pre name="code" class="java">
package org.primefaces.examples.view;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class ButtonBean {
	
	public void displayMessage(ActionEvent actionEvent) {
		addMessage("You said:'" + text + "'");
	}
	
	public void save(ActionEvent actionEvent) {
		addMessage("Data saved");
	}
	
	public void update(ActionEvent actionEvent) {
		addMessage("Data updated");
	}
	
	public void delete(ActionEvent actionEvent) {
		addMessage("Data deleted");
	}
	
	public void addMessage(String summary) {
		FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary,  null);
		FacesContext.getCurrentInstance().addMessage(null, message);
	}
}

			</pre>
				</p:tab>
			</p:tabView>

						
					</div>
				
	</ui:define>
</ui:composition>